package design.pattern.Observer;

import java.util.ArrayList;
import java.util.List;

public class WechatSubject implements Subject {

    List<User> userList = null;

    public WechatSubject() {
        this.userList = new ArrayList<>();
    }

    @Override
    public void register(User user) {
        this.userList.add(user);
    }

    @Override
    public void add(String message) {
        for (User user : this.userList) {
            user.update(message);
        }
    }

    @Override
    public void update(String message) {
        for (User user : this.userList) {
            user.update(message);
        }
    }

    @Override
    public void delete(String message) {
        for (User user : this.userList) {
            user.update(message);
        }
    }
}
